package com.ruicar.afs.cloud.workflow.greatwall.processor;

import com.ruicar.afs.cloud.workflow.greatwall.exception.FlowProcessException;
import com.ruicar.afs.cloud.workflow.greatwall.service.AfsGreatWallWorkflowBizDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;

@Slf4j
public abstract class AbsBaseProcessor implements BaseProcessor {
    protected final AfsGreatWallWorkflowBizDataService afsGreatWallWorkflowBizDataService;

    public AbsBaseProcessor(AfsGreatWallWorkflowBizDataService afsGreatWallWorkflowBizDataService) {
        this.afsGreatWallWorkflowBizDataService = afsGreatWallWorkflowBizDataService;
    }

    @Override
    public void checkException(String serviceId, String bizDataId) {
        if (afsGreatWallWorkflowBizDataService.exception(serviceId, bizDataId)) {
            log.warn("流程状态异常阻断请求:serviceId[{}],bizDataID[{}]", serviceId, bizDataId);
            throw new FlowProcessException(HttpStatus.INTERNAL_SERVER_ERROR, bizError);
        }
    }
}
